<?php
/**
 * 工厂抽象类
 *
 * @author maomao.thx@gmail.com
 * @copyright Copyright (c) 2009 Green Shore (http://www.iwgame.com)
 * @version $Id: FactoryAbstract.php 1059 2011-11-18 09:26:15Z mmxie $
 */
abstract class IG_Data_FactoryAbstract implements IG_Data_FactoryInterface
{
    /**
     *
     * @param Zend_Config|array $config
     */
    protected static function _factory($config, $defaultNamespace)
    {
        $config = IG_Config::convArray($config);
        //$namespace = isset($config['namespace']) ? $config['namespace'] : $defaultNamespace;
        $className =  $defaultNamespace . '_' . ucfirst($config['name']);
        if (class_exists($className) &&
            ($class = new $className($config['config'])) instanceof $defaultNamespace) {
            return $class;
        } else {
            throw new Exception("'$className' 方法不存在或没继承 '$defaultNamespace'");
        }
    }
}